package list_map.skipListMap;

import java.util.HashMap;
import java.util.Map;
import java.util.NavigableSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentNavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;

/**
 * @program: javase
 * @description:
 * @author: luolidong
 * @create: 2021-07-02 14:41
 * @version: 1.0
 */
public class Test1 {
    public static void main(String[] args) {
        //类似treeMap可以排序,线程安全，无锁
        ConcurrentSkipListMap<String, String> listMap = new ConcurrentSkipListMap<>();
        listMap.put("f", "f");
        listMap.put("s", "s");
        listMap.put("a", "e");
        listMap.put("q", "q");
        ConcurrentNavigableMap<String, String> s = listMap.headMap("s");
        System.out.println("s.get(\"s\") = " + s.get("a"));
        NavigableSet<String> strings = listMap.keySet();
        strings.forEach(System.out::println);
        Set<Map.Entry<String, String>> entries = listMap.entrySet();
        for(Map.Entry<String, String> entry:entries){
            System.out.println("key:"+entry.getKey()+" value:"+entry.getValue());
        }
//        HashMap;
//
//        ConcurrentHashMap
//        tableSizeFor(initialCapacity + (initialCapacity >>> 1) + 1));
//        ConcurrentHashMap(8) 8+8*2+1=25  tableSizeFor(25)  32
//        HashMap(8) tableSizeFor(8)  8

        System.out.println(127&1010);
        System.out.println(1010%128);
        System.out.println(75&100);
        System.out.println(100%76);
    }
}
